<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Carrinho de Compras</title>
	<link href="#{request.contextPath}/resources/CSS/style.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="#{request.contextPath}/resources/CSS/customizacao.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="#{request.contextPath}/resources/CSS/menus.css" rel="stylesheet" type="text/css" media="screen" />
</h:head>

<f:view encoding="ISO-8859-1"> 
	<h:body >
		<div class="nav">
		  <ul>
		  	<h:form id="form_menu_topo" style="margin-bottom: 0px !important;">
		  	
		   	   <c:if test="#{userSession == null and anuncianteSession == null}">
		   	   <p:growl id="growl" showDetail="true" sticky="true" />  
			   	   <li><a href="identifique-se.jsf" > Cadastrar</a> </li>
			   	   <!-- Login do usuario -->
					
					<li><p:outputLabel value="Login:" for="email"/></li>
					<li><p:inputText id="email" value="#{loginBean.email}" required="true" requiredMessage="Informe o Login!" /></li>
					<li><p:outputLabel value="Senha:" for="senha" /></li>
					<li><p:password id="senha" value="#{loginBean.senha}" required="true" requiredMessage="Informe a senha!" password="true"/></li>
					<li><p:commandLink value="Logar" action="#{loginBean.logar}" update="form_menu_topo growl :form_menus"  /></li>
					<li><a href="recuperarsenha.jsf" > Recuperar Senha</a> </li>
				</c:if>
				
				<c:if test="#{userSession != null}">
					<li>
						<h:outputLabel value="Seja Bem Vindo: #{userSession.nome} #{userSession.sobreNome}" id="user" />
					</li>
					
					<li>
						<h:commandLink action="configuracoesContaUsuario" immediate="true" value="Configurações Conta"/>
					</li>
					<li>
						<h:commandLink value="Sair" action="#{loginBean.sair}"  update="@all">
						    <f:setPropertyActionListener target="#{loginBean.atributoSessao}" value="userSession"></f:setPropertyActionListener>
						</h:commandLink>
					</li>
				</c:if>
				
				<c:if test="#{anuncianteSession != null}">
					<li>
						<h:outputLabel value="Seja Bem Vindo: #{anuncianteSession.razaoSocial}" id="user" />
					</li>
					<li>
						<h:commandLink action="configuracoesContaAnunciante"  value="Configurações Conta" immediate="true"/>
					</li>
					<li>
						<h:commandLink value="Sair" action="#{loginBean.sair}"  update="@all">
						    <f:setPropertyActionListener target="#{loginBean.atributoSessao}" value="anuncianteSession"></f:setPropertyActionListener>
						</h:commandLink>
					</li>
				</c:if>
				
		   	</h:form>
		  </ul>
		</div>
		<div id="banner">
			<div id="areaPesquisa">
				<h:form id="form_pesquisa">
					<p:inputText id="texto" value="#{vitrineBean.searchInput}" label="texto"/>
					<p:watermark for="texto" value="Digite seu produto" />  
					<p:commandButton id="submit" action="#{vitrineBean.pesquisar}" value="Buscar Produto" process="@form" update="@all" ajax="false"/>						
				</h:form> 
			</div>
			<div id="carrinho">
				<h:form id="form_carrinho">
					<p:graphicImage value="../resources/images/carrinho.png" alt="logo do site" height="140px" /><br/>
					<h:commandLink action="#{carrinhoBean.mostrarCarrinho}" immediate="true" value="Total carrinho: R$ ">
						<h:outputLabel value="#{carrinhoBean.total}">
							<f:converter converterId="valorConverter"></f:converter>
							<f:convertNumber minFractionDigits="2" locale="PT_BR" ></f:convertNumber>
						</h:outputLabel>
					</h:commandLink><br></br>
				</h:form>
			</div>
		</div>
			<div id="menu">
				<h:form id="form_menus">
					<ul id="nav">
						<h:commandLink action="#{vitrineBean.iniciar}" value="Inicio" immediate="true"/>
					</ul>
					 <ul id="nav">
						<h:commandLink action="#{anuncianteBean.tabelaAnunciante}" immediate="true">
							<h:outputText value="Anunciantes"></h:outputText>
						</h:commandLink>
					</ul>
					 <ul id="nav">
						<h:commandLink action="#{produtoBean.produtosAnunciante}" immediate="true">
							<h:outputText value="Produtos Cadastrados"></h:outputText>
						</h:commandLink>
					</ul>
					
					<!-- Mostrar somente quando a lista tiver algum produto -->
					<c:if test="#{carrinhoBean.total != 0}">
						<ul id="nav">
							<h:commandLink action="#{compararListaBean.novaComparacao}" value="Comparar Lista" immediate="true"/>
						</ul>
					</c:if>
					
					<c:if test="#{userSession != null}">
						<ul id="nav">
							<h:commandLink action="#{listaComprasBean.minhasListas}" value="Minhas listas" immediate="true"/>
						</ul>
					</c:if>
					
					<c:if test="#{userSession.tipoUsuario == 'A' || anuncianteSession != null}">
						<ul id="nav">	
							<h:commandLink action="#{produtoBean.novoProduto}" immediate="true">
								<h:outputText value="Cadastrar Produto"></h:outputText>
							</h:commandLink>
						</ul>
						<ul id="nav">	
							<h:commandLink action="#{categoriaBean.addCategoria}" immediate="true">
								<h:outputText value="Cadastrar Categoria"></h:outputText>
							</h:commandLink>
						</ul>
						<ul id="nav">	
							<h:commandLink action="#{categoriaBean.tebelaCategorias}" immediate="true">
								<h:outputText value="Tabela de Categorias"></h:outputText>
							</h:commandLink>
						</ul>
					</c:if>	
					<c:if test="#{anuncianteSession == null}">
						<ul id="nav">
							<h:commandLink value=" Anuncie-aqui" action="#{anuncianteBean.novoAnunciante}" immediate="true" />
						</ul>
					</c:if>
				</h:form>
			</div>
		
		<div id="container">
			<div id="content_left">
				<dl class="curved">
					<dt>Categorias</dt>
					<dd>
						<br />
						<h:form id="menusCategorias">
							<div id='cssmenu'>
							  <ul>
				   		   	   	<c:forEach items="#{categoriaBean.listCategorias}" var="cat0">
								  <li class='active'> 
								    <h:commandLink action="#{vitrineBean.buscarProdutosCategoria}" value="#{cat0.nome}">
								  	  <f:setPropertyActionListener target="#{vitrineBean.categoria}" value="#{cat0}"/>
								    </h:commandLink>
									<ul>
								      <c:forEach items="#{cat0.categoriasFilhas}" var="cat1">
									  	 <li class='active'> 
									  	     <h:commandLink action="#{vitrineBean.buscarProdutosCategoria}" value="#{cat1.nome}">
										  	 	<f:setPropertyActionListener target="#{vitrineBean.categoria}" value="#{cat1}"/>
								 			 </h:commandLink>
								   			 <ul>
								   			   <c:forEach items="#{cat1.categoriasFilhas}" var="cat2">
									  			  <li class='active'> 
									  			    <h:commandLink action="#{vitrineBean.buscarProdutosCategoria}" value="#{cat2.nome}">
									  			      <f:setPropertyActionListener target="#{vitrineBean.categoria}" value="#{cat2}"/>
								 			        </h:commandLink>
									  			    <ul>
									  			      <c:forEach items="#{cat2.categoriasFilhas}" var="cat3">
									  				     <li class='active'> 
									  				        <h:commandLink action="#{vitrineBean.buscarProdutosCategoria}" value="#{cat3.nome}">
									  				           <f:setPropertyActionListener target="#{vitrineBean.categoria}" value="#{cat3}"/>
								 			                </h:commandLink>
									  			         </li>
									   			      </c:forEach>
									  	 		    </ul>
									  	 		  </li>
								      		  </c:forEach>	
								   			 </ul>
								  		 </li>
								      </c:forEach>
									</ul>
								  </li>
		        			    </c:forEach>
							  </ul>
							</div>
						</h:form>
						<p class="last">&nbsp;</p>
					</dd>
				</dl>
			</div>
			<div id="content">
				<ui:insert name="conteudo">
	
				</ui:insert>
			</div>
		</div>
	
		<div id="footer">
			<h:form id="form_footer">
				<h:commandLink value=" Anuncie-aqui" action="cadastrarAnunciante"
					immediate="true" />
			</h:form>
		</div>
	</h:body>
</f:view>
</html>